﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Web.UI.MobileControls;
using System.Collections.Generic;

namespace PublicService
{
    public partial class Reports : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string path = MapPath("Reports");
            string[] htm_files = Directory.GetFiles(path, "*.htm");
            List<string> files = new List<string>();
            string[] xml_files = Directory.GetFiles(path, "*.xml");
            string text = "<h3 align=center>Отчёты на сервере</h3>";
            for (int i = 0; i < htm_files.Length; i++)
            {
                files.Add(htm_files[i]);
                htm_files[i] = htm_files[i].Substring(htm_files[i].LastIndexOf('\\')+1);
                xml_files[i] = xml_files[i].Substring(xml_files[i].LastIndexOf('\\')+1);
            }
            if (htm_files.Length == 0)
                text += "На сервере нет файлов.";
            else
            {
                text += "<table align='center' border='1' cellspacing='0' cellpadding=5>";
                text += "<caption>Файлов на сервере: " + htm_files.Length.ToString() + "</caption>";
                text += "<tr><td bgcolor='#6666ff' align='center'>Дата</td><td bgcolor='#6666ff'>Html отчёт</td><td bgcolor='#6666ff'>Xml данные</tr></th>";
                for (int i = 0; i < htm_files.Length; i++)
                {
                    text += "<tr><td>" + File.GetCreationTime(files[i]).ToLocalTime() + "</td>";
                    text += "<td><img border=0 src='/reports/report.png'><a style='color:navy' href='/reports/" + htm_files[i] + "'>Показать</a></td>";
                    text += "<td><img border=0 src='/reports/data.png'><a style='color:navy' href='/reports/" + xml_files[i] + "'>Скачать</a></a></td></tr>";
                }
                text += "</table><br /> <font color='grey'>---<br>code by jcorp.ru</font>";
            }
            form1.InnerHtml = text;
        }
    }
}
